package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoInformationShopping;
import com.muyu.danmo.service.IDanmoInformationShoppingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人信息名家推荐Controller
 * 
 * @author kunzong
 * @date 2024-12-11
 */
@RestController
@RequestMapping("/DanmoInformationShopping")
public class DanmoInformationShoppingController extends BaseController
{
    @Autowired
    private IDanmoInformationShoppingService danmoInformationShoppingService;

    /**
     * 查询个人信息名家推荐列表
     */
//    @RequiresPermissions("system:DanmoInformationShopping:list")
    @GetMapping("/list")
    public Result list(DanmoInformationShopping danmoInformationShopping)
    {
        startPage();
        List<DanmoInformationShopping> list = danmoInformationShoppingService.selectDanmoInformationShoppingList(danmoInformationShopping);
        return Result.success(list);
    }

    /**
     * 导出个人信息名家推荐列表
     */
//    @RequiresPermissions("system:DanmoInformationShopping:export")
    @Log(title = "个人信息名家推荐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationShopping danmoInformationShopping)
    {
        List<DanmoInformationShopping> list = danmoInformationShoppingService.selectDanmoInformationShoppingList(danmoInformationShopping);
        ExcelUtil<DanmoInformationShopping> util = new ExcelUtil<DanmoInformationShopping>(DanmoInformationShopping.class);
        util.exportExcel(response, list, "个人信息名家推荐数据");
    }

    /**
     * 获取个人信息名家推荐详细信息
     */
//    @RequiresPermissions("system:DanmoInformationShopping:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoInformationShoppingService.selectDanmoInformationShoppingById(id));
    }

    /**
     * 新增个人信息名家推荐
     */
//    @RequiresPermissions("system:DanmoInformationShopping:add")
    @Log(title = "个人信息名家推荐", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoInformationShopping danmoInformationShopping)
    {
        return    danmoInformationShoppingService.insertDanmoInformationShopping(danmoInformationShopping);

    }

    /**
     * 修改个人信息名家推荐
     */
//    @RequiresPermissions("system:DanmoInformationShopping:edit")
    @Log(title = "个人信息名家推荐", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationShopping danmoInformationShopping)
    {
        return Result.success(danmoInformationShoppingService.updateDanmoInformationShopping(danmoInformationShopping));
    }

    /**
     * 删除个人信息名家推荐
     */
//    @RequiresPermissions("system:DanmoInformationShopping:remove")
    @Log(title = "个人信息名家推荐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoInformationShoppingService.deleteDanmoInformationShoppingByIds(ids));
    }
}
